package com.advertisementsystem.Controller;

import com.advertisementsystem.Exception.ResponseResult;
import com.advertisementsystem.Servie.DashboardService;
import com.advertisementsystem.utils.SecurityUtils;
import com.advertisementsystem.vo.DashboardVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/dashboard")
@PreAuthorize("hasRole('ADVERTISER')")
public class DashboardController {

    @Autowired
    private DashboardService dashboardService;

    @GetMapping
    public ResponseResult<DashboardVO> getDashboardData() {
        Long advertiserId = SecurityUtils.getUserId();
        return ResponseResult.success(dashboardService.getDashboardData(advertiserId));
    }
}
